package demo.ClassLoad;

import java.lang.reflect.Modifier;
import java.util.Arrays;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/5-08-05-9:49
 * @Description：demo.ClassLoad     反射获取信息
 */
public class reflect_ClassSelf {
    public static void main(String[] args) {
        //类的基本信息
        Class<Student> c = Student.class;

        //获取运行时字节码信息
        System.out.println(c.getName());      //demo.ClassLoad.Student
        System.out.println(c.getSimpleName());    //Student
        System.out.println(Modifier.toString(c.getModifiers()));    //类的修饰符
        //类所在包
        System.out.println(c.getPackage());      //package demo.ClassLoad

        //父类
        System.out.println(c.getSuperclass());     //class java.lang.object

        //接口数组
        System.out.println(Arrays.toString(c.getInterfaces()));   //[]

        //是否为基本数据类型
        System.out.println(c.isPrimitive());      //false
        System.out.println(int.class.isPrimitive());     //true
        System.out.println(Integer.class.isPrimitive());    //false

        //是否是父类
        System.out.println(c.isAssignableFrom(reflect.class));    //false
    }
}
